const MonacoWebpackPlugin = require('monaco-editor-esm-webpack-plugin')
const path = require('path')
const resolve = dir => {
  return path.join(__dirname, dir)
}

module.exports = {
  configureWebpack: {
    module: {
      rules: [
        {
          test: /\.js/,
          enforce: 'pre',
          include: /node_modules[\\\/]monaco-editor[\\\/]esm/,
          use: MonacoWebpackPlugin.loader
        }
      ]
    },
    plugins: [new MonacoWebpackPlugin()]
  },
  chainWebpack: config => {
    config.resolve.alias
      .set('@', resolve('src')) // key,value自行定义，比如.set('@@', resolve('src/components'))
      .set('public', resolve('public'))
    // 移除 prefetch 插件
    config.plugins.delete('prefetch')
    // 移除 preload 插件
    config.plugins.delete('preload')
    config.output.globalObject('this')
    config.output.filename('js/[name].[hash].js').end()
  },
  lintOnSave: false
}
